package com.framework.boc.admin.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.framework.boc.admin.entity.Menu;
import com.framework.boc.admin.service.impl.MenuServiceImpl;
import com.framework.boc.response.CommonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.framework.boc.controller.BaseController;

import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author Leil
 * @since 2020-07-01
 */
@RestController
@RequestMapping("/admin/menu")
public class MenuController extends BaseController {

    @Autowired
    MenuServiceImpl menuService;

    @PreAuthorize("hasRole('admin')")
    @GetMapping("/list")
    public CommonResponse list() {
        List<Menu> list = menuService.list();
        return CommonResponse.success(list);
    }


    @GetMapping("byId")
    public CommonResponse getById(@RequestParam("id") int id) {
        Menu menu = this.menuService.selectMenuById(id);
        return CommonResponse.success(menu);
    }

}

